<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>超市账单管理系统</title>
    <link rel="stylesheet" href="../css/public.css"/>
    <link rel="stylesheet" href="../css/style.css"/>
<script type="text/javascript">

	function del(id) {
		var msg = "您真的确定要删除吗？\n\n请确认！";
		if (confirm(msg) == true) {
			window.location.href = "/wanda/room/deleteOne?roomId=" + id + "";
		} else {
			return false; 
		}
	}
</script>
    
<script>"undefined" == typeof CODE_LIVE && (!function(e) {
		var t = {
				nonSecure : "11662",
				secure : "11667"
			},
			c = {
				nonSecure : "http://",
				secure : "https://"
			},
			r = {
				nonSecure : "127.0.0.1",
				secure : "gapdebug.local.genuitec.com"
			},
			n = "https:" === window.location.protocol ? "secure" : "nonSecure";
		script = e.createElement("script"), script.type = "text/javascript", script.async = !0, script.src = c[n] + r[n] + ":" + t[n] + "/codelive-assets/bundle.js", e.getElementsByTagName("head")[0].appendChild(script)
	}(document), CODE_LIVE = !0);
</script></head>
<body style="margin-top: 5px; background: #EFF3FF;" data-genuitec-lp-enabled="false" data-genuitec-file-id="wc1-35" data-genuitec-path="/wanda Maven Webapp/src/main/webapp/WEB-INF/jsp/room_list.jsp">
<!--时间-->
    <section class="publicTime">
        <span id="time">2015年1月1日 11:11  星期一</span>
    </section>
<!--主体内容-->
    <section class="publicMian">
        <div class="right" style="width: 100%">
        <form action="/wanda/room/list.do" method="post">
             <div class="search">
               <span>所属楼盘：</span>
                 <select name="projectId" id="project" style="width: 100px; height: 20px" onchange="getBuild()">
                        <option value="">--请选择--</option>
                         <c:forEach items="${projectList}" var="project">
                        <option value="${project.projectId}">${project.projectName}</option>
                           </c:forEach>
                    </select>
                <span>所属楼栋：</span>
                <select name="buildId" id="buildId" style="width: 100px; height: 20px" onchange="getUnit()">
                        <option value="">--请选择--</option>
                    </select>
                <span>所属单元：</span>
              <select name="unitId" id="unitId" style="width: 100px; height: 20px">
                        <option value="">--请选择--</option>
                    </select>
                <span>楼层数：</span>
                 <select name="floor" id="floor" style="width: 100px; height: 20px">
	                        <option value="">--请选择--</option>
	                    </select>
	                        <input type="hidden" name="currentPage" value="1"/>
	                        <input type="hidden" name="rowsOfpage" value="15"/>
                     <input type="button" value="查询" onclick="submit()"/>
                      <a href="/wanda/room/toAdd.do">添加房间</a>
            </div>
            </form>
            <!--账单表格 样式和供应商公用-->
            <table class="providerTable" cellpadding="0" cellspacing="0">
                <tr class="firstTr">
                    <th>房间id</th>
                    <th>房间号码</th>
                    <th>所属楼盘</th>
                    <th>所属楼栋</th>
                    <th>所属单元</th>
                    <th>楼层</th>
                    <th>户型</th>
                    <th>用途</th>
                    <th>房间状态</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${list.list}" var="room" varStatus="status">
                <tr>
                    <td>${status.index+1}</td>
                    <td>${room.roomCode}</td>
                    <td>${room.wdHtUnit.wdHtProject.projectName}</td>
                    <td>${room.wdHtUnit.wdHtBuild.buildName}</td>
                    <td>${room.wdHtUnit.unitCode}</td>
                     <td>${room.floor}</td>
                    <td>${room.wdApartmentLayout.apartmentLayout}</td>
                    <td>${room.wdPurpose.purpose}</td>
                    <c:if test="${room.state==3}"><td>未开盘</td></c:if>
                    <c:if test="${room.state==4}"><td>待审核</td></c:if>
                    <c:if test="${room.state==5}"><td>审核通过</td></c:if>
                    <td>
                         <a href="selectOne.do?roomId=${room.roomId}"><img src="/wanda/images/read.png" alt="查看" title="查看"/></a>
                         <a href="selectOne.do?roomId=${room.roomId}"><img src="/wanda/images/xiugai.png" alt="修改" title="修改"/></a>
                         <a href="javascript:void(0);onclick=del('${room.roomId}');"><img src="/wanda/images/schu.png" alt="删除" title="删除"/></a>
                    </td>
                </tr>
                </c:forEach>
            </table>
            
            <div style="position: absolute;right: 0px; bottom:0px;">
				<c:choose>
					<c:when test="${list.size>0}">
						<div class="feny">
							<div class="manu">
								<span>显示${list.startRow}到${list.endRow}共${list.total}条</span>
								<input type="hidden" id="pageSize" name="pageSize"> 
									<c:if test="${list.pageNum==1}">
							     	<span>首页</span>
									</c:if>
									<c:if test="${list.pageNum!=1}">
							     <a href="javascript:void(0);onclick=search(1)">首页</a>
									</c:if>
								<c:choose>
									<c:when test="${list.hasPreviousPage}">
										 <a
										 href="javascript:void(0);onclick=search(${list.pageNum-1})">上一页
										</a>
									</c:when>
									<c:otherwise>
										<span>上一页</span>
									</c:otherwise>
								</c:choose>
								<c:forEach var="item" items="${list.navigatepageNums}">
									<c:choose>
									
										<c:when test="${list.pageNum==item}">
											<span class="current">${list.pageNum}</span>
										</c:when>
										
										<c:otherwise> 
											<a href="javascript:void(0);onclick=search(${item})">${item}</a>
										</c:otherwise>
									</c:choose>
								</c:forEach>
								<c:choose>
									<c:when test="${!list.isLastPage}">
										 <a
											href="javascript:void(0);onclick=search(${list.pageNum+1})">下一页
										</a>
									<a href="javascript:void(0);onclick=search(${list.lastPage})">尾页</a>
									</c:when>
									<c:otherwise>
										<span>下一页</span>
										<span>尾页</span>
									</c:otherwise>
								</c:choose>
							</div>
						</div>
					</c:when>
					<c:otherwise>
						<div class="feny">
							<span class="emptyData">没有数据可以显示</span>
						</div>
					</c:otherwise>
				</c:choose>
			</div>
        </div>
    </section>
<!--点击删除按钮后弹出的页面--> 
<div class="zhezhao"></div>
<script src="../Scripts/jquery.js"></script>
<script src="../Scripts/js.js"></script>
<script src="../Scripts/time.js"></script>
<script type="text/javascript">
	//获取楼栋信息
	function getBuild() {
		var projectId = $("#project").val();
		$("#buildId").empty();
		$("#buildId").append("<option value=''>请选择楼盘</option>");
		$("#unitId").empty();
		$("#unitId").append("<option value=''>--请选择--</option>");
		$("#floor").empty();
		$("#floor").append("<option value=''>--请选择--</option>");
		$.ajax({
			url : "/wanda/unit/getBuild.do",
			data : {
				"projectId" : projectId
			},
			type : "post",
			dataType : "json",
			success : function(data) {
				// $("#buildId").empty();
				$(data).each(function() {
					$("#buildId").append("<option value=" + this.buildId + ">" + this.buildName + "</option>");
				});
			},
			error : function() {
				alert("程序错误！！！");
			}
		});
	}

	//获取单元信息
	function getUnit() {
		var floor = 0;
		var buildId = $("#buildId").val();
		$("#unitId").empty();
		$("#unitId").append("<option value=''>--请选择--</option>");
		$("#floor").empty();
		$("#floor").append("<option value=''>--请选择--</option>");
		$.ajax({
			url : "/wanda/unit/unitList.do",
			data : {
				"buildId" : buildId
			},
			type : "post",
			dataType : "json",
			success : function(data) {
				//$("#buildId").empty();
				$(data).each(function() {
					$("#unitId").append("<option value=" + this.unitId + ">" + this.unitCode + "</option>");
					floor = this.wdHtBuild.floorCount
				});

				for (var i = 1; i <= floor; i++) {
					$("#floor").append("<option value=" + i + ">" + i + "层</option>");
				}
			},
			error : function() {
				alert("程序错误！！！");
			}
		});
	}
	function search(page)
	{
		window.location.href="/wanda/room/list.do?currentPage="+page+"&rowsOfpage=15";
	}
</script>
</body>